import { createRouter, createWebHistory } from 'vue-router'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
        {
            path: "/",
            redirect: '/index',
            component: ()=>import('@/views/homeView.vue')
        }, 
        {
            path: "/index",
            component: ()=>import('@/views/homeView.vue')
        }, 
        {
            path: "/rank",
            component: ()=>import("@/views/rank.vue")
        }, 
        {
            path: "/playlist",
            component: ()=>import('../views/playlistView.vue')
        }, 
        {
            path: "/mvlist",
            component: ()=>import("@/views/mvView.vue")
        }, 
        {
            path: "/artist",
            component: ()=>import('@/views/artist.vue')
        }, 
        {
        path: "/atristMusic",
        name:"atristMusic",
        component: ()=>import('../views/artistMusic.vue')
        }, 
        {
            path: "/my",
            component: ()=>import('@/views/homeView.vue'),
            beforeEnter:(()=>{
                ElNotification({
                    message: `<div style="display:flex;align-items: center;">
                    <img width='50px' src="http://127.0.0.1:5173/src/assets/OIP-C.jpg"/>
                    <span>我的音乐还未开发！</span></div>`,
                    showClose: false,
                    dangerouslyUseHTMLString:true,
                    duration:2000,
                    position: 'top-left',
                })
            })
        }, 
        {

            path: "/mvplay/:id",
            name:"mvplay",
            component: ()=>import('@/views/mvPlayView.vue'),
            beforeEnter:((to,from)=>{
                console.log("StopMusic")
            })
        }, 
        {
            path: "/search/:keywords",
            name:"search",
            component: ()=>import("@/views/searchView.vue"),

        }, 
        
        {
            path: "/songCardDetail",
            name:"songcarddetail",
            component: ()=>import('../views/songCardDetail.vue')
        }

   
  ]
})
router.beforeEach((to, from) => {
    if(to.name=='search'){

    }else{
        ElNotification({
        message: `<div style="display:flex;align-items: center;"><img width='50px' src="http://127.0.0.1:5173/src/assets/OIP-C.jpg"/><span>正在加载...</span></div>`,
        showClose: false,
        dangerouslyUseHTMLString:true,
        duration:1000,
        position: 'top-left',
     })
    }
  
})

export default router
